package com.itogis.rest.datasource;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.wabacus.config.Config;

/**
 * wabacus 数据源的获取
 * @author Administrator
 *
 */
public class DataSourceManager {
	/**
	 * 获取链接
	 * @return
	 */
	public static Connection  getConnection(){
		return Config.getInstance().getDataSource("ds_oracle").getConnection();
	}
	
	/**
	 * 关闭链接对象
	 * @param rs
	 * @param st
	 * @param cn
	 */
	public static void closeConnection(ResultSet rs,Statement st,Connection cn){
		try {
			if(rs!=null){
				rs.close();
			}
			if(st!=null){
				st.close();
			}
			if(cn!=null&&!cn.isClosed()){
				cn.close();
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
}
